package com.company;



public class ClassLoaderChecker {

    public static void main(String[] args) throws ClassNotFoundException,IllegalAccessException,InstantiationException{

        MyClassLoader m=new MyClassLoader("/Users/Luke/Desktop/","Luke");

        /**
         * Loads the class with the specified <a href="#name">binary name</a>.
         * This method searches for classes in the same manner as the {@link
         * #loadClass(String, boolean)} method.  It is invoked by the Java virtual
         * machine to resolve class references.  Invoking this method is equivalent
         * to invoking {@link #loadClass(String, boolean) <tt>loadClass(name,
         * false)</tt>}.
         *
         * @param  name
         *         The <a href="#name">binary name</a> of the class
         *
         * @return  The resulting <tt>Class</tt> object
         *
         * @throws  ClassNotFoundException
         *          If the class was not found
         */

        //其实这就是一个反射的过程
        Class c=m.loadClass("Luke");
        System.out.println(c.getClassLoader());
        System.out.println(c.getClassLoader().getParent());
        System.out.println(c.getClassLoader().getParent().getParent());
        System.out.println(c.getClassLoader().getParent().getParent().getParent());
        //利用class对像实例化Luke对象
        c.newInstance();
    }
}
